package com.fuxi.cloud.config.client;

import cn.hutool.core.util.ObjectUtil;
import com.fuxi.cloud.api.JmReportTokenServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * JmReportTokenClient
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
@Component("jmReportTokenClient")
public class JmReportTokenClient {
    @Autowired(
            required = false
    )
    private JmReportTokenServiceI jimuTokenService;

    public JmReportTokenClient() {
    }

    public String getToken(HttpServletRequest request) {
        String var2 = "";
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var2 = this.jimuTokenService.getToken(request);
        }

        return var2;
    }

    public String getToken() {
        String var1 = "";
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var1 = this.jimuTokenService.getToken();
        }

        return var1;
    }

    public String getUsername(String token) {
        String var2 = "admin";
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var2 = this.jimuTokenService.getUsername(token);
        }

        return var2;
    }

    public String getUsername(HttpServletRequest request) {
        String var2 = "admin";
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var2 = this.jimuTokenService.getUsername(this.getToken(request));
        }

        return var2;
    }

    public String getUsername() {
        String var1 = "admin";
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var1 = this.jimuTokenService.getUsername(this.getToken());
        }

        return var1;
    }

    public boolean verifyToken(HttpServletRequest request) {
        Boolean var2 = true;
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            String var3 = this.getToken(request);
            var2 = this.jimuTokenService.verifyToken(var3);
        }

        return var2;
    }

    public Map<String, Object> getUserInfo(String token) {
        Map var2 = null;
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var2 = this.jimuTokenService.getUserInfo(token);
        }

        return var2;
    }

    public HttpHeaders customApiHeader() {
        HttpHeaders var1 = null;
        if (ObjectUtil.isNotEmpty(this.jimuTokenService)) {
            var1 = this.jimuTokenService.customApiHeader();
        }

        return var1;
    }
}

